Skip to content

Improve import scanning performance on app dev#6930

Draft
gonzaloriestra wants to merge 2 commits intomainfrom
improve-import-scanning-perf
Draft

Improve import scanning performance on app dev#6930
gonzaloriestra wants to merge 2 commits intomainfrom
improve-import-scanning-perf

Conversation

@gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Mar 3, 2026

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/21853

WHAT is this pull request doing?

How to test your changes?

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@gonzaloriestra
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260303123133

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.9% 14556/18449
🟡 Branches 73.2% 7235/9884
🟡 Functions 79.05% 3695/4674
🟡 Lines 79.24% 13759/17363

Test suite run success

3792 tests passing in 1451 suites.

Report generated by 🧪jest coverage report action from 013a52a

@gonzaloriestra gonzaloriestra force-pushed the improve-import-scanning-perf branch 2 times, most recently from 51fc769 to 2aa31b8 Compare March 4, 2026 08:43
@gonzaloriestra
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260304084414

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra gonzaloriestra force-pushed the improve-import-scanning-perf branch from 2aa31b8 to 013a52a Compare March 4, 2026 09:15
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/constants.d.ts
@@ -32,6 +32,7 @@ export declare const environmentVariables: {
     neverUsePartnersApi: string;
     skipNetworkLevelRetry: string;
     maxRequestTimeForNetworkCalls: string;
+    disableImportScanning: string;
 };
 export declare const defaultThemeKitAccessDomain = "theme-kit-access.shopifyapps.com";
 export declare const systemEnvironmentVariables: {
packages/cli-kit/dist/public/node/import-extractor.d.ts
@@ -1,6 +1,12 @@
+/**
+ * Clears all import-scanning caches (direct imports, recursive results, and filesystem stats).
+ * Should be called when watched files change so that rescanning picks up updated imports.
+ */
+export declare function clearImportPathsCache(): void;
 /**
  * Extracts import paths from a source file.
  * Supports JavaScript, TypeScript, and Rust files.
+ * Results are cached per file path to avoid redundant I/O.
  *
  * @param filePath - Path to the file to analyze.
  * @returns Array of absolute paths to imported files.
@@ -17,6 +23,17 @@ export declare function extractImportPaths(filePath: string): string[];
  * @throws If an unexpected error occurs while processing files (not including ENOENT file not found errors).
  */
 export declare function extractImportPathsRecursively(filePath: string, visited?: Set<string>): string[];
+/**
+ * Returns diagnostic information about the import scanning caches.
+ * Useful for debugging performance issues with --verbose.
+ *
+ * @returns Cache size stats for directImports, fileExists, and isDir.
+ */
+export declare function getImportScanningCacheStats(): {
+    directImports: number;
+    fileExists: number;
+    isDir: number;
+};
 /**
  * Extracts import paths from a JavaScript content.
  *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant